class NetUtil:
    """
    网络工具类
    """

    @staticmethod
    def get_request_ip(request):
        x_forwarded_for = request.headers.get("X-Forwarded-For")
        if x_forwarded_for:
            # 提取最左边的 IP 地址
            ip = x_forwarded_for.split(",")[0]
        else:
            ip = request.client.host
        return ip
